<?php
/**
 * Created by PhpStorm.
 * User: mars
 * Date: 2019/2/7
 * Time: 4:43 PM
 */

namespace api\controllers;


use api\models\JobType;
use api\models\SearchPart;
use common\libs\Constants;

class JobTypeController extends BaseController
{
    public $modelClass = 'api\models\JobType';


    public function actionJob()
    {
        $model = JobType::find()->where(['type' => JobType::TYPE_JOB])->all();

        return $model;
    }

    public function actionMission()
    {
        $model = JobType::find()->where(['type' => JobType::TYPE_MISSION])->all();

        return $model;
    }

    public function actionDefault()
    {
        $res   = [];
        $types = Constants::getSearchPartTypes();
        foreach ($types as $key => $value) {
            $res[$key] = [];
            array_push($res[$key], SearchPart::find()->where(['type' => $key])->all());
        }

        return $res;

    }


}